<!DOCTYPE html>
<html>
<head lang="zh-CN">
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta name="keywords" content="">
<meta name="description" content="">
<meta name="format-detection" content="telephone=no, email=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<link rel="apple-touch-icon-precomposed" href="<%=basePath%>favicon.ico" />

<script>
	var _provinceId = '';
	var isLogin = 'false' == 'true';
</script>

<title>登录</title>
<link rel="stylesheet" href="<%=basePath%>css/common/normalize.css">
<link rel="stylesheet" href="<%=basePath%>css/common/iconfont.css">
<link rel="stylesheet" href="<%=basePath%>/css/user/login.css">
</head>
<body>
	<div class="m-wrapper">

	<jsp:include page="header_member.jsp"></jsp:include>

		<div class="content box-tab" id="box-main">
			<span class="clear"></span>
			<div class="pad30">
				<div class="tinput">
					<i class="icon-font icon-people licon d3"></i> <i
						class="icon-font ricon d3 icon_close"></i> <input class="pinput"
						type="text" id="mobileNum" value="" name="mobileNum"
						placeholder="请输入用户名/手机号">
				</div>
				<div class="tinput">
					<i class="icon-font icon-lock licon d3 "></i> <input class="pinput"
						type="password" id="password" name="password" placeholder="请输入密码">
				</div>
				<div class="martop1">
					<i class="icon-font icon-checkbox-checked wred licon " id="remPas"></i>
					两周内自动登录
				</div>

				<a class="logbtn" id="memberLogin" href="javascript:void(0);">登
					录</a> <a href="javascript:void(0);" class="logbtn submiting"
					style="display:none;">快速登录中...</a>
				<div class="plass" id="plass" style=" display: none">请输入密码</div>
				<ul class="martop1">
					<li class="fleft"><a href="<%=basePath%>mobile/mobile_register">免费注册</a></li>
					<li class="fright"><a
						href="<%=basePath%>mobile/forgetpwdstep1">忘记密码</a></li>
				</ul>
				<span class="clear"></span>


			</div>
			<div class="fs_login">
				<span class="l_line"></span> <a href="javascript:void(0);">快捷登录</a>
				<span class="r_line"></span>
			</div>


			<div class="klogin">
				<ul class="loginul">
					</li>
					<li class="weixin"><a href="/mobile/member/authWeixin.html">微信</a>
					</li>
				</ul>
				<span class="clear"></span>
			</div>

		</div>

		<div class="tc_loading">
			<img src="<%=basePath%>/img/loading.gif" width="28px" height="28px">
			<div>加载中…</div>
		</div>
		<!--tab category:end-->

		<jsp:include page="footer.jsp"></jsp:include>

	</div>
	
<style>
.tc_loading {
	z-index: 9998;
	width: 36%;
	height: 60px;
	text-align: center;
	border-radius: 5px;
	position: fixed;
	top: 50%;
	left: 50%;
	margin-top: -35px;
	margin-left: -18%;
	font-size: 14px;
	color: #fff;
	background-color: rgba(0, 0, 0, .7);
	padding-top: 10px;
	display: none;
}
</style>

	<input id="type" type="hidden" value="${method}">
		
	<script type="text/javascript" src="<%=basePath%>js/zepto.min.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/util.js"></script>
	<script type="text/javascript" src="<%=basePath%>js/head.js"></script>
			
<script type="text/javascript">

	var isLogin = false;
	var params = G.util.url.getArguments();
	$('.mobpay a').attr('href', '/mobile/member/toMemberRegistSms.html?returnUrl=' + encodeURIComponent(params.returnUrl));
	if(isLogin && params['returnUrl'])
		location.href = params['returnUrl'];
	
	if(location.href != top.location.href)
		top.location.href = location.href;
	
    // 两周内免登陆flg
    var remPasFlg = true;

    $('#remPas').on('click', function () {
        if(remPasFlg){
            $(this).removeClass('wred');
            $(this).removeClass('icon-checkbox-checked');
            $(this).addClass('icon-unchecked');
            remPasFlg = false;
        }else{
            $(this).addClass('wred');
            $(this).addClass('icon-checkbox-checked');
            $(this).removeClass('icon-unchecked');
            remPasFlg = true;
        }
    });

    $(".pinput").on("keyup", function () {
        if($(this).val()){
            $(this).parent().children(".icon_delete").addClass("icon-close");
            $(this).parent().children(".pinput").removeClass("bred");
//            $("#mobileNum").addClass("bred");
        }else{
            $(this).parent().children(".icon_delete").removeClass("icon-close");
        }
    });

    $(".icon_delete").on("click", function () {
        $(this).removeClass("icon-close");
        $(this).parent().children("input").val("").focus();
        if($(this).next().attr('id') == 'mobileNum'){
        	$('#password').val('');
        }
    });
    //表单提交
    $("#memberLogin").click(function(){
        if(!checkForm()){
            return false;
        }
        var username = $("#mobileNum").val();
        var password = $("#password").val();
        var data = {
        				phone: username,
        				pwd: password,
		                remPasFlg: remPasFlg
		            };
        if($('#imgCaptcha').length > 0)
        	data.validCode = $('#imgCaptcha').val();
        $(this).hide();
        $(".submiting").show();
        $.ajax({
            type: "post",
            url: "<%=basePath%>mobile/login",
            data: data,
            dataType: "json",
            success: function(result) {
                if(result.code == "0000"){
                	//登录成功
                	location.href="<%=basePath%>mobile/user_center";
                }else{
                	if($('#imgCaptcha').length > 0){
                		$('#getImgCaptcha').attr('src', '/mobile/member/getImgCaptcha.html?'+new Date().getTime());
                	}
                    if(result.message == 'pc用户手机号未验证'){
                        if(confirm("该手机号码已绑定您的邮箱账号，但未通过验证，您可以选择使用邮箱登录，或者点击确认去验证手机号")){
                            window.location.href = "/mobile/member/toMemberVerifyMobile.html?mobileNum="+username;
                        }
                    }else if(result.message == "是创客用户"){
                        if(confirm("您是创客用户，请到创客平台登录")){
                            window.location.href = "/mobile/ck/toCertify.html";
                        }
                        $("#memberLogin").show();
                        $(".submiting").hide();
                    }else if(result.errorCode == 'ALLOW_ERROR_COUNT' && $('#imgCaptcha').length == 0){
                    	alert(result.message);
                    	$("#memberLogin").show();
                        $(".submiting").hide();
                        $('#password').parent().after('<div class="tinput">\
                                <input class="npinput" type="text" placeholder="请输入验证码" id="imgCaptcha">\
                                <img id="getImgCaptcha" name="getImgCaptcha" onclick="this.src=\'/mobile/member/getImgCaptcha.html?\'+new Date().getTime()" src="/mobile/member/getImgCaptcha.html" class="vecode">\
                            </div>');
                    }else{
                        alert(result.message);
                        $("#memberLogin").show();
                        $(".submiting").hide();
                    }
                }
            }
        });
    });

    //表单校验
    function checkForm(){
        var mobileNum = $("#mobileNum").val();
        var password = $("#password").val();
        var mobileReg = /^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\d{8}$/;
        var emailReg = /^([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)*@([a-zA-Z0-9]*[-_]?[a-zA-Z0-9]+)+[\\.][A-Za-z]{2,3}([\\.][A-Za-z]{2})?$/;

        if(mobileNum == "" || mobileNum == null){
            $("#mobileNum").addClass("bred");
            alert("用户名不能为空！");
            return false;
        }
//			if(!mobileReg.test(mobileNum) && !emailReg.test(mobileNum)){
//				alert("用户名不正确");
//				return false;
//			}
        if(password == "" || password == null){
            $("#password").addClass("bred");
            alert("请输入密码！");
            return false;
        }
        return true;
    }

    //手机号校验
    function isMobileNO(mobileNum){
//			var pattern = new RegExp("^((13[0-9])|(14[0-9])|(15[0-9])|(17[0-9])|(18[0-9]))\\d{8}$");
//			if(!pattern.test(mobileNum)){
//				$("#mobileNumMsg").text("用户名不正确！");
//				return false;
//			}
//			$("#mobileNumMsg").empty();
        return true;
    }

    //输入框样式
    $(".Login_top>ul>li").on("click",function(){
        var i=$(this).prev().length;
        $("div div.Login_bottom").eq(i).show().siblings().hide();
        $(this).addClass("cur").siblings().removeClass("cur");
        $("#login_errorMsg").text('');
    });

</script>

</body>
</html>